package com.faceboob.api;

import org.apache.http.client.HttpClient;

import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.FacebookClient.AccessToken;
import com.restfb.Parameter;
import com.restfb.types.FacebookType;

public class test {

	/**
	 * @param args
	 */

	private static FacebookClient facebookClient;
//	
//	public void makeWallPost(){
//        HttpClient client = null;
//        PostMethod method = null;
//        String urlStr = null;
//        String linkText = ""; //Facebook page name or alias
//        String linkURL = ""; //Facebook page URL
//        String response = null;
//        String accessToken = null;
//
//        try{
//            urlStr = "https://graph.facebook.com/$PROFILE_ID$/feed";
//            urlStr = urlStr.replace("$PROFILE_ID$", facebookId);
//            accessToken = getAccessToken();//[USER ACCESS TOKEN]
//            client = new HttpClient();
//            method = new PostMethod(urlStr);
//            method.setRequestHeader("pageEncoding", "UTF-8");
//            method.setRequestHeader("Content-Type", "text/html; charset=UTF-8");
//
//            method.addParameter("access_token", accessToken);
//            method.addParameter("message", "");
//            method.addParameter("link", "Link of wall post header");
//            method.addParameter("name", "Header of wall post");
//            method.addParameter("actions", "[{\"name\": \"" + linkText + "\" , \"link\": \"" + linkURL + "\"}]");
//
//            method.addParameter("caption", " ");
//            method.addParameter("description", "message body here");
//            method.addParameter("picture", "http://www.example.com/test.jpg");
//            client.executeMethod(method);
//            response = method.getResponseBodyAsString();
//           }
//           catch(Exception e){
//
//           }
//           finally{
//               method.releaseConnection();
//           }
//
//    }

	public static void main(String[] args) {

//		AccessToken accessToken = new DefaultFacebookClient()
//				.obtainExtendedAccessToken(
//						"139384839574556",
//						"83bdd08fa6634d80a693b77525b8f7db",
//						"BAACEdEose0cBAOrh4j7EsDZAnOFCyYWmS8ybJTRjGFvK2ZBertEqeG7WAd2CqZCjp0wv7zmwIjX4MvtY0ADuEk55EwpqzLebvgPrIVsjhFLU4HxheauristU4kA6upEYKNZCbaZCPRL4ZADQecwZBZB2E8AJnPGGi0wEmLknzR0ZBjOZCzlVoklKlXUg1CTJo96i8gKlLFTCDECAZDZD");
//
//		System.out.println(accessToken.getAccessToken());
		facebookClient = new DefaultFacebookClient("BAACEdEose0cBAOrh4j7EsDZAnOFCyYWmS8ybJTRjGFvK2ZBertEqeG7WAd2CqZCjp0wv7zmwIjX4MvtY0ADuEk55EwpqzLebvgPrIVsjhFLU4HxheauristU4kA6upEYKNZCbaZCPRL4ZADQecwZBZB2E8AJnPGGi0wEmLknzR0ZBjOZCzlVoklKlXUg1CTJo96i8gKlLFTCDECAZDZD");

		System.out.println("* Feed publishing *");

		FacebookType publishMessageResponse = facebookClient.publish(
				"JavaSupport/feed", FacebookType.class,
				Parameter.with("link", "http://www.google.com"),
				Parameter.with("message", "RestFB test"));

		System.out.println("Published message ID: "
				+ publishMessageResponse.getId());

	}

}
